<?php

namespace Acme\BlogBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

use S3\BlogBundle\Entity\Author;
//use S3\BlogBundle\Form\AuthorType;


class BlogController extends Controller
{
    
    public function indexAction($name)
    {
    	$author = new Author();
    	
    	// do something to author object
    	/* if($name != '123123')
    	{
    		$author->name = $name;
    	} */    	
    	
    	$validator = $this->get('validator');    	
    	$errors = $validator->validate($author);    	
    	if(count($errors) > 0)
    	{
    		return new Response(print_r($errors, true) );
    	}
    	return new Response('author is valid!');
      //return $this->render('S3BlogBundle:Default:index.html.twig', array('name' => $name));
    }
    
    /* public function showAction($slug)
    {
    	$blog = $slug;// use slug variable to query database
    	
    	// $router = $this->get('router');
    	
    	// array('slug' => 'my-blog-post', _controller => 'S3BlogBundle:Blog:show')
    	//$params = $router->match('blog/my-blog-post');
    	
    	// uri = '/blog/my-blog-post'
    	//$uri = $router->generate('blog_show', array('slug' => 'my-blog-post'));      	
    	
    	return $this->render('AcmeBlogBundle:Blog:show.html.twig', array('blog' => $blog));
    }
    
    public function updateAction(Request $request)
    {
    	$author = new Author();
    	$form = $this->createForm(new AuthorType(), $author);
    	
    	if($request->getMethod() == 'POST')
    	{
    		$form->bindRequest($request);
    		
    		if($form->isValid())
    		{
    			// validation is passed, do something with the $author object
    			//$this->redirect($this->generateUrl('...'));
    		}
    	}
    	
    	return $this->render('BlogBundle:Author:form.html.twig', array('form' => $form->createView()));
    } */
}
